'use strict'
const path = require('path')
const defaultSettings = require('./src/settings.js')
const CopyWebpackPlugin = require("copy-webpack-plugin") // 配置vueconfigjs 将项目中某一个文件打包后放置dist内的根目录下(微信支付txt)

function resolve(dir) {
  return path.join(__dirname, dir)
}

const name = defaultSettings.title || 'vue Element Admin' // page title

// If your port is set to 80,
// use administrator privileges to execute the command line.
// For example, Mac: sudo npm run
// You can change the port by the following method:
// port = 9527 npm run dev OR npm run dev --port = 9527
const port = process.env.port || process.env.npm_config_port || 9527 // dev port

// All configuration item explanations can be find in https://cli.vuejs.org/config/
module.exports = {
  publicPath: '/', // 打包地址
  outputDir: 'dist', // 打包文件
  assetsDir: 'static', // 严谨模式
  lintOnSave: false, // 关闭eslint
  productionSourceMap: true,
  devServer: {
    port: port,
    open: true, // 自动打开open
    inline: true, /// 热更新
    proxy: {
      '/apl': {
        target: process.env.VUE_APP_BASE_API,
        changeOrigin: true,
        WebSocket: false,
        pathRewrite: {
          '^/apl': ''
        }
      }
    },
  },
  configureWebpack: {
    // provide the app's title in webpack's name field, so that
    // it can be accessed in index.html to inject the correct title.
    name: name,
    resolve: {
      alias: {
        '@': resolve('src')
      }
    }
  },
  configureWebpack: config => {
    config.plugins = [
      ...config.plugins,
      new CopyWebpackPlugin({
        patterns: [{
          from: "src/*.txt",
          to: "[name].[ext]"
        }]
      })
    ]
  },
  // css: {
  //   loaderOptions: {
  //     scss: {
  //       prependData: `@import "~@/styles/variables.scss";`
  //     }
  //   }
  // }
  css: {
		loaderOptions: {
			sass: {

			},
		},
	},
}
